package com.example.firstapp.service

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder

class MyService : Service() {
    private val mBinder = DownloadBinder()
    // 新建下载的类
    class DownloadBinder:Binder(){
        fun startDownload(){
            println("开始下载")
        }fun getProgress(): Int {
            println("获取进度")
            return 0
        }
    }
    override fun onCreate() {
        super.onCreate()
        println("MyService创建完成")
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        println("MyService启动完成")
        return super.onStartCommand(intent, flags, startId)
    }

    override fun onDestroy() {
        super.onDestroy()
        println("MyService销毁成功")
    }

    override fun onBind(intent: Intent?): IBinder? {
        return mBinder
    }
}